* File names and labels variables of data set "final_results_subjects.csv"
* File generates new variables for analyses


clear

set mem 500m

use "final_results_subjects.dta"

set more off
set more off, permanently



*******************************************************************
***	Definitions of labels used in dataset
*******************************************************************


label define lb_sessionid 1 "11.07.2016, 12:00"
label define lb_sessionid 2 "11.07.2016, 14:00", add
label define lb_sessionid 3 "11.07.2016, 16:00", add
label define lb_sessionid 4 "13.07.2016, 14:00", add
label define lb_sessionid 5 "11.07.2016, 16:00", add
label define lb_sessionid 6 "06.10.2016, 10:00", add

label define lb_treatment 1 "Treatment 1"
label define lb_treatment 2 "Treatment 2", add
label define lb_treatment 3 "Treatment 3", add

label define lb_type 1 "Player A"
label define lb_type 2 "Player B", add
label define lb_type 3 "Player C", add
label define lb_type 4 "Player D", add
label define lb_type 5 "Player E", add

label define lb_yes_no 1 "yes"
label define lb_yes_no 0 "no", add

label define lb_noanswer -99 "no answer"

label define lb_sex 0 "female"
label define lb_sex 1 "male", add
label define lb_sex -99 "no answer", add

label define lb_yes_no_noanswer 0 "no"
label define lb_yes_no_noanswer 1 "yes", add
label define lb_yes_no_noanswer -99 "no answer", add

label define lb_proposer_dec 0 "Proposal to adjourn"
label define lb_proposer_dec 1 "Proposal new point", add
label define lb_proposer_dec 2 "Agendasetter timed out", add

label define lb_decision 1 "Status quo maintained"
label define lb_decision 2 "Proposed new point accepted", add
label define lb_decision 3 "Continue decision making", add
label define lb_decision 4 "Adjourn decision making", add
label define lb_decision 5 "Agendasetter timed out", add

label define lb_prop -99 "Agendasetter made no proposal"

label define lb_adj -99 "Agendasetter did not propose to adjourn"

label define lb_final -99 "No final decision reached so far in period"

label define lb_vote_prop 0 "No"
label define lb_vote_prop 1 "Yes", add
label define lb_vote_prop -99 "Agendasetter made no proposal", add

label define lb_vote_adj 0 "No"
label define lb_vote_adj 1 "Yes", add
label define lb_vote_adj -99 "Agendasetter did not propose to adjourn", add

label define lb_final_yes_no 0 "No"
label define lb_final_yes_no 1 "Yes", add
label define lb_final_yes_no -99 "No final decision reached so far in period", add

label define lb_prop_yes_no 0 "No"
label define lb_prop_yes_no 1 "Yes", add
label define lb_prop_yes_no -99 "Agendasetter made no proposal", add


*******************************************************************
***	Naming and labeling of variables in dataset
*** Generation of new variables for analyses
*******************************************************************

* sessionid
label variable sessionid "Session ID"
label values sessionid lb_sessionid
notes sessionid : Date and starting time of session

*treatment
label variable treatment "Treatment"
label values treatment lb_treatment

*period
label variable period "Period"

*subject
label variable subject "Subject ID in session"

*group
label variable group "Group ID in session"

*groupid
label variable groupid "Group ID"
notes groupid: Treatment_Group

*subjectid
label variable subjectid "Subject ID"
notes subjectid: Treatment_Group_Type

*decisionid1
label variable decisionid1 "Decision ID 1"
notes decisionid1: Treatment_Period_Group_Type

*decisionid2
label variable decisionid2 "Decision ID 2"
notes decisionid2: Treatment_Group_Type_Period

*decisionid3
label variable decisionid3 "Decision ID 3"
notes decisionid3: Treatment_Group_Period

*type
label variable type "Type"
label values type lb_type

*final_x
label variable final_x "x-coordinate of selected point in period"

*final_y
label variable final_y "y-coordinate of selected point in period"

*vote_adj
label variable vote_adj "Did subject vote 'adjourn'?"
label values vote_adj lb_yes_no

*vote_cont
label variable vote_cont "Did subject vote 'continue'?"
label values vote_cont lb_yes_no

*vote_a_adj
label variable vote_a_adj "Did Player A vote 'adjourn'?"
label values vote_a_adj lb_yes_no

*vote_b_adj
label variable vote_b_adj "Did Player B vote 'adjourn'?"
label values vote_b_adj lb_yes_no

*vote_c_adj
label variable vote_c_adj "Did Player C vote 'adjourn'?"
label values vote_c_adj lb_yes_no

*vote_d_adj
label variable vote_d_adj "Did Player D vote 'adjourn'?"
label values vote_d_adj lb_yes_no

*vote_e_adj
label variable vote_e_adj "Did Player E vote 'adjourn'?"
label values vote_e_adj lb_yes_no

*vote_a_cont
label variable vote_a_cont "Did Player A vote 'continue'?"
label values vote_a_cont lb_yes_no

*vote_b_cont
label variable vote_b_cont "Did Player B vote 'continue'?"
label values vote_b_cont lb_yes_no

*vote_c_cont
label variable vote_c_adj "Did Player C vote 'continue'?"
label values vote_c_adj lb_yes_no

*vote_d_cont
label variable vote_d_cont "Did Player D vote 'continue'?"
label values vote_d_cont lb_yes_no

*vote_e_cont
label variable vote_e_cont "Did Player E vote 'continue'?"
label values vote_e_cont lb_yes_no

*sum_adj
label variable sum_adj "Number of group members voting 'adjourn'"

*sum_cont
label variable sum_cont "Number of group members voting 'continue'"

sort subjectid period

*age
label variable age "Age of participant"
generate age2 = age[_n+1]
replace age = age2 if age==-99
drop age2

*sex
label variable sex "Participant's gender"
generate sex2 = sex[_n+1]
replace sex = sex2 if sex==-99
drop sex2
label values sex lb_sex

*student
label variable student "Is participant student?"
generate student2 = student[_n+1]
replace student = student2 if student==-99
drop student2
replace student =. if student==-99

*semester
label variable semester "Number of semesters studied by participant"
generate semester2 = semester[_n+1]
replace semester = semester2 if semester==-99
drop semester2
replace semester =. if semester==-99

*discipline
label variable discipline "Field of study"

*econ_student
label variable econ_student "Economics student"
generate econ_student2 = econ_student[_n+1]
replace econ_student = econ_student2 if econ_student==-99
drop econ_student2
replace econ_student =. if econ_student==-99

*language
label variable language "First language"

*language_german
label variable language_german "First language German"
generate language_german2 = language_german[_n+1]
replace language_german = language_german2 if language_german==-99
drop language_german2
replace language_german =. if language_german==-99

*experience
label variable experience "Experimental experience"
generate experience2 = experience[_n+1]
replace experience = experience2 if experience==-99
drop experience2
replace experience =. if experience==-99
notes experience: Wie oft haben Sie vor dem heutigen Experiment an einem Experiment des Kölner Laboratoriums für Wirtschaftsforschung teilgenommen? (Falls Sie es nicht genau wissen, geben Sie bitte einen ungefähren Wert an.)

*criteria_dec
label variable criteria_dec "Criteria for decision"
notes criteria_dec: Nach welchen Kriterien haben Sie Ihre Entscheidungen im Experiment getroffen?

*comments
label variable comments "Further comments"
notes comments: Haben Sie weitere Kommentare oder Anmerkungen zum Experiment?

*guess
label variable guess "Subject's guess in guessing game"
generate guess2 = guess[_n+1]
replace guess = guess2 if guess==-99
drop guess2

*dictator_give
label variable dictator_give "Number of points sent by subject in dictator game"
generate dictator_give2 = dictator_give[_n+1]
replace dictator_give = dictator_give2 if dictator_give==-99
drop dictator_give2

*dictator_receive
label variable dictator_receive "Number of points received by subject in dictator game"
generate dictator_receive2 = dictator_receive[_n+1]
replace dictator_receive = dictator_receive2 if dictator_receive==-99
drop dictator_receive2

*your_sender
label variable your_sender "Sender matched with subject in dictator game"
generate your_sender2 = your_sender[_n+1]
replace your_sender = your_sender2 if your_sender==-99
drop your_sender2
label values type lb_type

*your_receiver
label variable your_receiver "Receiver matched with subject in dictator game"
generate your_receiver2 = your_receiver[_n+1]
replace your_receiver = your_receiver2 if your_receiver==-99
drop your_receiver2
label values type lb_type

* time_in_stage2
label variable time_in_stage2 "Time for committee decision"

*proposer
label variable proposer "Is player proposer in period?"
label values proposer lb_yes_no

*type_agendasetter
label variable type_agendasetter "Last proposer in period"
label values type_agendasetter lb_type

* num_ag
label variable num_ag "Number of proposers in group until final decision"

* fin_points
label variable fin_points "Number of points earned by subject in period"

* fin_points_A - fin_points_E
label variable fin_points_a "Number of points earned by Player A in period"
label variable fin_points_b "Number of points earned by Player B in period"
label variable fin_points_c "Number of points earned by Player C in period"
label variable fin_points_d "Number of points earned by Player D in period"
label variable fin_points_e "Number of points earned by Player E in period"

* time_in_stage_quest
label variable time_in_stage_quest "Time spent for answering questionnaire"
generate time_in_stage_quest2 = time_in_stage_quest[_n+1]
replace time_in_stage_quest = time_in_stage_quest2 if time_in_stage_quest==-99
drop time_in_stage_quest2

* left_right
label variable left_right "Left-right self-evaluation"
destring left_right, replace
generate left_right2 = left_right[_n+1]
replace left_right = left_right2 if left_right==-99
drop left_right2
notes left_right: Viele Leute verwenden die Begriffe 'links' und 'rechts', wenn es darum geht, unterschiedliche politische Einstellungen zu kennzeichnen. Wie würden Sie ganz allgemein Ihren eigenen politischen Standort beschreiben: Wo auf dieser Skala würden Sie sich selbst einstufen?
notes left_right: 1 = Links; 7 = Rechts; 7

*trust
label variable trust "Generalized social trust"
destring trust, replace
generate trust2 = trust[_n+1]
replace trust = trust2 if trust==-99
drop trust2
notes trust: Ganz allgemein, was meinen Sie: Kann man Menschen vertrauen oder kann man im Umgang mit Menschen nicht vorsichtig genug sein?
notes trust: 1='Man kann Menschen fast immer vertrauen'; 2='Man kann Menschen normalerweise vertrauen';  3='Man kann normalerweise nicht vorsichtig genug sein im Umgang mit Menschen'; 4='Man kann fast nie vorsichtig genug sein im Umgang mit Menschen';

*justice1
notes justice1: Es ist gerecht, wenn Personen, die im Beruf viel leisten, mehr verdienen als andere.
notes justice1: 1 = stimme voll zu; 5 = lehne ganz ab;

*justice2
notes justice2: Gerecht ist, wenn alle die gleichen Lebensbedingungen haben.
notes justice2: 1 = stimme voll zu; 5 = lehne ganz ab;

*justice3
notes justice3: Eine Gesellschaft ist gerecht, wenn sie sich um die Schwachen und Hilfsbedürftigen kümmert.
notes justice3: 1 = stimme voll zu; 5 = lehne ganz ab;

*justice4
notes justice4: Gerecht ist, wenn jede Person nur das bekommt, was sie sich durch eigene Anstrengung erarbeitet hat.
notes justice4: 1 = stimme voll zu; 5 = lehne ganz ab;

*justice5
notes justice5: Es ist gerecht, wenn Einkommen und Vermögen in unserer Gesellschaft an alle Personen gleich verteilt sind.
notes justice5: 1 = stimme voll zu; 5 = lehne ganz ab; 

*justice6
notes justice6: Es ist gerecht, wenn Personen, die aus angesehenen Familien stammen, dadurch Vorteile im Leben haben.
notes justice6: 1 = stimme voll zu; 5 = lehne ganz ab;

generate justice12 = justice1[_n+1]
generate justice22 = justice2[_n+1]
generate justice32 = justice3[_n+1]
generate justice42 = justice4[_n+1]
generate justice52 = justice5[_n+1]
generate justice62 = justice6[_n+1]
replace justice1 = justice12 if justice1==-99
replace justice2 = justice22 if justice2==-99
replace justice3 = justice32 if justice3==-99
replace justice4 = justice42 if justice4==-99
replace justice5 = justice52 if justice5==-99
replace justice6 = justice62 if justice6==-99
drop justice12 justice22 justice32 justice42 justice52 justice62

*time_in_stage_guess
label variable time_in_stage_guess "Time needed for decision in guessing game"
generate time_in_stage_guess2 = time_in_stage_guess[_n+1]
replace time_in_stage_guess = time_in_stage_guess2 if time_in_stage_guess==-99
drop time_in_stage_guess2

*time_in_stage_dict
label variable time_in_stage_dict "Time needed for decision in dictator game"
generate time_in_stage_dict2 = time_in_stage_dict[_n+1]
replace time_in_stage_dict = time_in_stage_dict2 if time_in_stage_dict==-99
drop time_in_stage_dict2

*gesamtauszahlung
label variable gesamtauszahlung "Total payout"
notes gesamtauszahlung: pointsineuro + lump-sum payment of 4 EURO

* final_ucset
generate final_ucset = 0
label variable final_ucset "Is final result in uncovered set"
label values final_ucset lb_yes_no
replace final_ucset = 1 ///
	if ///
	(final_y == 51 & final_x == 49) | ///
	(final_y == 50 & final_x >= 44 & final_x<=54) | ///
	(final_y == 49 & final_x >= 39 & final_x<=59.5) | ///
	(final_y == 48 & final_x >= 37.5 & final_x<=60.3) | ///
	(final_y == 47 & final_x >= 37.5 & final_x<=60.8) | ///
	(final_y == 46 & final_x >= 37.5 & final_x<=60.8) | ///
	(final_y == 45 & final_x >= 37.5 & final_x<=60.8) | ///
	(final_y == 44 & final_x >= 37.5 & final_x<=60.2) | ///
	(final_y == 43 & final_x >= 38 & final_x<=60.8) | ///
	(final_y == 42 & final_x >= 38 & final_x<=60.8) | ///
	(final_y == 41 & final_x >= 38 & final_x<=60.8) | ///
	(final_y == 40 & final_x >= 38 & final_x<=59.8) | ///
	(final_y == 39 & final_x >= 39 & final_x<=59.3) | ///
	(final_y == 38 & final_x >= 39 & final_x<=59.3) | ///
	(final_y == 37 & final_x >= 40 & final_x<=58.3) | ///
	(final_y == 36 & final_x >= 41 & final_x<=56.8) | ///
	(final_y == 35 & final_x >= 42 & final_x<=55)

